﻿@model  RestApp.UI.Core.UsersGridSettings

<div class="panel panel-default">
    <div class="panel-heading">
        Сотрудники
    </div>
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-striped table-bordered table-hover" id="usersList">
                <thead>
                    <tr>
                        <th>
                            Id
                        </th>
                        <th>
                            Фамилия
                        </th>
                        <th>Имя</th>
                        <th>Отчество</th>
                        <th>Дата рождения</th>
                        <th>Дата приема</th>
                        <th>Действия</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var user in Model.Users)
                    {
                        <tr>
                            <td>@user.Id</td>
                            <td>@user.LastName</td>
                            <td>@user.FirstName</td>
                            <td>@user.MiddleName</td>
                            @if (user.DateBirth != null)
                            {
                                <td>@user.DateBirth.Value.ToShortDateString()</td>
                            }
                            else
                            {
                                <td>-</td>
                            }
                            <td>@user.StartWorkDate.ToShortDateString()</td>
							<td>
								@if (User.IsInRole("Admin"))
								{
									@Html.ActionLink("Подробно", "Details", "ManageUsers", new { id = user.Id }, null) @:|
									@Html.ActionLink("Редактировать", "Edit", "ManageUsers", new { id = user.Id }, null) @:|
									@Html.ActionLink("Удалить", "Delete", "ManageUsers", new { id = user.Id }, new { onclick = "return confirm('Вы уверены, что хотите удалить пользователя?');" })
								}
                                else if(User.IsInRole("Manager"))
                                {
                                    if (Model.GridType == RestApp.UI.Core.UsersGridType.Report)
                                    {
                                        @Html.ActionLink("Построить отчет", "WorkTimeForUserParameters", "Reports", new { idUser = user.Id }, null)
                                    }
                                    if (Model.GridType == RestApp.UI.Core.UsersGridType.Simple)
                                    {
                                        @Html.ActionLink("График работы", "Graphic", "Calendar", new { id = user.Id }, null);
                                    }
                                    else if (Model.GridType == RestApp.UI.Core.UsersGridType.JobFacts)
                                    {
                                        @Html.ActionLink("Заполнить факты", "FillFacts", "JobFacts", new { id = user.Id }, null);
                                    }
                                }
								else if (User.IsInRole("User"))
								{
									if (Model.GridType == RestApp.UI.Core.UsersGridType.Simple)
									{
										@Html.ActionLink("График работы", "Graphic", "Calendar", new { id = user.Id }, null);
									}
									else if(Model.GridType == RestApp.UI.Core.UsersGridType.JobFacts)
									{
										@Html.ActionLink("Заполнить факты", "FillFacts", "JobFacts", new { id = user.Id }, null);
									}
								}
							</td>



                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>







